﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <link href="/CSS/bootstrap3.3.5/css/bootstrap.css" rel="stylesheet" type="text/css" />
    <link href="/CSS/V3/style.css?v=2.2.0" rel="stylesheet">
    <link href="/CSS/font-awesome-4.3.0/css/font-awesome.min.css" rel="stylesheet">
    <link href="/JqueryPlug/dtGrid/jquery.dtGrid.css" rel="stylesheet">
    <link href="/CSS/Base/BaseClass.css?cssver=4" rel="stylesheet">
    <script src="/Scripts/jquery-1.11.2.min.js"></script>
    <script src="/JqueryPlug/laypage/laypage.js"></script>
    <script src="/CSS/bootstrap3.3.5/js/bootstrap.js"></script>
    <script src="/Scripts/avalon.js"></script>
    <script src="/Scripts/SZHLCommon.js?jsver=5"></script>
    <script src="/JqueryPlug/dtGrid/jquery.dtGrid.js"></script>
    <style>
        .btn:hover .btndel {
            visibility: visible;
        }

        .btn .btndel {
            visibility: hidden;
        }

        .btndel {
            color: red;
        }

        .lev2 {
            padding-left: 40px;
        }
    </style>
    <script type="text/javascript">
        var grid, dtoption;
        var model = avalon.define({
            $id: "APP_TXL",
            BranchData: [],
            BranchListData: [],
            ColumnData: [],//个人通讯录类型
            grtxlData: [],//个人通讯录数据
            SelDeptItem: {},
            GetUserList: function (item) {
                var deptCode = 1;
                if (item != null) {
                    deptCode = item.DeptCode;
                }
                $.getJSON('/API/SZHLAPI.ashx?Action=GETUSERBYCODE', { "P1": deptCode, P2: $("#tbSearch").val() }, function (resultData) {
                    if (resultData.ErrorMsg == "") {
                        grid.originalDatas = resultData.Result
                        grid.load()
                        model.SelDeptItem = item == null ? {} : item;
                    }
                })
            },
            curTagName: "",

            searchContent: "",
            GetTXLList: function (tagName) {
                model.curTagName = tagName;
                //已添加的记事本
                $.getJSON('/API/FTAPI.ashx?Action=GETUSERTXLLIST_PAGE', { P1: model.searchContent, P2: model.curTagName, p: 1 }, function (resultData) {
                    if (resultData.ErrorMsg == "") {
                        model.grtxlData = resultData.Result;
                        laypage({
                            cont: 'pageDiv', //容器。值支持id名、原生dom对象，jquery对象。
                            pages: Math.ceil(parseInt(resultData.Result1) * 1.0 / 8), //通过后台拿到的总页数
                            curr: 1, //初始化当前页
                            jump: function (e) { //触发分页后的回调
                                $.getJSON('/API/FTAPI.ashx?Action=GETUSERTXLLIST_PAGE', { P1: model.searchContent, P2: model.curTagName, p: e.curr }, function (resultData) {
                                    model.grtxlData = resultData.Result;
                                })
                            }
                        });
                    }
                })
            },
            addTXL: function () {
                parent.ComFunJS.winviewform("/View/APPBaseView/APP_ADD_WF.html?FormCode=TXL", "添加数据", "1000", "");
            },
            ViewForm: function (ID) {
                parent.ComFunJS.winviewform("/View/APPBaseView/APP_ADD_WF.html?FormCode=TXL&pageType=edit&ID=" + ID, "数据编辑", "1000", "");
            },
            DELForm: function (item) {
                parent.ComFunJS.winconfirm("确认要删除么", function () {
                    $.post("/API/FTAPI.ashx?ACTION=DELTXLBYID", { P1: item.ID }, function (result) {
                        var jsonresult = $.parseJSON(result)
                        if ($.trim(jsonresult.ErrorMsg) == "") {
                            model.grtxlData.remove(item);
                            parent.ComFunJS.winsuccess('删除成功');
                        }
                    });
                }, function () { })
            }, DelTag: function (item, event) {
                if (event) {
                    event.stopPropagation();
                }
                parent.ComFunJS.winconfirm("确认要删除“" + item.TagName + "”么", function () {
                    $.post("/API/FTAPI.ashx?ACTION=DELTAGBYID", { P1: item.ID }, function (result) {
                        var jsonresult = $.parseJSON(result)
                        if ($.trim(jsonresult.ErrorMsg) == "") {
                            model.ColumnData.remove(item);
                            alert("操作成功");
                        }
                    });
                }, function () { })
            }

        });
        avalon.ready(function () {
            //获取主要菜单
            dtoption = {
                lang: 'zh-cn',
                check: false,
                ajaxLoad: false,
                exportFileName: '用户列表',
                columns: [
                    { id: 'UserRealName', title: '用户名', type: 'string', columnClass: 'text-center' },
                    { id: 'DeptName', title: '所在部门', type: 'string', columnClass: 'text-center' },
                    { id: 'mobphone', title: '手机号', type: 'string', columnClass: 'text-center' },
                    { id: 'zhiwu', title: '职务', type: 'string', columnClass: 'text-center' },
                    { id: 'mailbox', title: '邮箱', type: 'string', columnClass: 'text-center' }


                ],
                gridContainer: 'dtgrid',
                toolbarContainer: 'dtgridTool',
                pageSize: 10,
                pageSizeLimit: [10, 20, 50],
                tools: 'faseQuery',
                onGridComplete: function (grid) {
                    var log = '<p>表格加载完成。表格编号：' + grid.option.id + '。</p>';
                }
            };
            $.getJSON('/API/SZHLAPI.ashx?Action=GETAllBMLIST', { P1: "1" }, function (resultData) {
                if (resultData.ErrorMsg == "") {
                    model.BranchData = resultData.Result;
                    avalon.scan()
                    if (model.BranchData.size() > 0) {
                        $.getJSON('/API/SZHLAPI.ashx?Action=GETUSERBYCODE', { "P1": 1 }, function (resultData) {
                            if (resultData.ErrorMsg == "") {
                                dtoption.datas = resultData.Result;
                                grid = $.fn.DtGrid.init(dtoption);
                                grid.load()
                            }
                        })
                    }
                }
            })

            $.getJSON('/API/FTAPI.ashx?Action=GETTAGLIST', { P1: "TXL" }, function (resultData) {
                if (resultData.ErrorMsg == "") {
                    model.ColumnData = resultData.Result;
                }
            })
            model.GetTXLList("");
        })
    </script>
</head>
<body class="gray-bg " ms-controller="APP_TXL">
    <div class="wrapper wrapper-content  animated fadeInRight blog">
        <div class="tabs-container">
            <ul class="nav nav-tabs">
                <li class="active">
                    <a data-toggle="tab" href="#tab-qytxl" aria-expanded="true"> 企业通讯录</a>
                </li>
                <li>
                    <a data-toggle="tab" href="#tab-grtxl" aria-expanded="false">个人通讯录</a>
                </li>
            </ul>
            <div class="tab-content">
                <div id="tab-qytxl" class="tab-pane active" style="    padding: 10px 0;">
                    <div class="row">
                        <div class="col-sm-3">
                            <div class="panel panel-default">
                                <!-- Default panel contents -->
                                <div class="panel-heading"><a style="cursor:pointer" ms-click="GetUserList(null)">企业通讯录</a></div>
                                <!-- Default panel contents -->
                                <div class="panel-heading"><a href="#" ms-click="GetUserList(null, null)">组织机构（全部人员）</a></div>
                                <!-- List group -->
                                <ul class="list-group" ms-each-bm="BranchData">
                                    <li class="list-group-item" ms-class="active:bm.DeptCode==SelDeptItem.DeptCode" ms-click="GetUserList(bm)">
                                        {{bm.DeptName}}
                                    </li>
                                    <ui class="list-group" ms-each-item="bm.xsbm">
                                        <li class="list-group-item lev2" ms-class="active:item.DeptCode==SelDeptItem.DeptCode" ms-click="GetUserList(item)"> {{item.DeptName}}</li>
                                    </ui>
                                </ul>
                                <!-- List group -->
                                <!--<ul class="list-group">
                                    <li class="list-group-item" ms-repeat-item="BranchData" ms-class="active:item.DeptCode==SelDeptItem.DeptCode" ms-attr-id="item.DeptCode" ms-click="GetUserList(item)">
                                        <span class="label label-info" style="float:right">{{item.userCount}}</span> <span>{{item.DeptName}}</span>
                                    </li>
                                </ul>-->
                            </div>
                        </div>
                        <div class="col-sm-9">
                            <div class="input-group" style=" padding:5px;">
                                <input type="text" class="input form-control" id="tbSearch" placeholder="姓名,部门,手机号...">
                                <span class="input-group-btn">
                                    <button type="button" class="btn btn btn-primary" ms-click="GetUserList(SelDeptItem)"> <i class="fa fa-search"></i> 搜索</button>
                                </span>
                                <div id="pageDiv" class="text-right"></div>
                            </div>
                            <div id="dtgrid" style="margin-top:20px"></div>
                            <div id="dtgridTool" class="dt-grid-toolbar-container"></div>
                        </div>
                    </div>
                </div>
                <div id="tab-grtxl" class="tab-pane">
                    <div class="row">
                        <div class="col-sm-3">
                            <div class="ibox float-e-margins">
                                <div class="ibox-content" style="border: 0; border-right: 1px solid #e7eaec;">
                                    <div class="file-manager">
                                        <div class="hr-line-dashed"></div>
                                        <button class="btn btn-primary btn-block" ms-click="addTXL()">添加联系人</button>
                                        <div class="hr-line-dashed"></div>
                                        <h5 class="tag-title">分类</h5>
                                        <button class="btn  btn-sm " ms-class-1="btn-primary:model.curTagName==''" ms-click="GetTXLList('')" ms-class-2="btn-white:model.curTagName!=''" style="margin-right:5px" type="button">全部</button>
                                        <button class="btn  btn-sm " ms-repeat-item="ColumnData" ms-class-1="btn-primary:model.curTagName==item.TagName" ms-click="GetTXLList(item.TagName)" ms-class-2="btn-white:model.curTagName!=item.TagName" style="margin-right:5px" type="button">{{item.TagName}}&nbsp;<i class='iconfont icon-guanbi btndel' ms-click="DelTag(item,event)"></i></button>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="col-sm-9">
                            <div class="ibox">
                                <div class="pull-right mail-search">
                                    <div class="input-group">
                                        <input type="text" class="form-control input-sm" ms-duplex="searchContent" name="search" placeholder="输入联系人姓名">
                                        <div class="input-group-btn">
                                            <button type="submit" class="btn btn-sm btn-primary" ms-click="GetTXLList('')">
                                                搜索
                                            </button>
                                        </div>
                                    </div>
                                </div>
                                <h2>
                                    个人通讯录
                                </h2>
                                <div class="mail-tools tooltip-demo m-t-md">
                                    <div class="btn-group pull-right">
                                        <div id="pageDiv"></div>
                                    </div>
                                    <div class="clearfix"></div>
                                </div>
                                <div class="table-responsive">
                                    <table class="table table-striped table-hover">
                                        <thead>
                                            <tr>
                                                <th>序号</th>
                                                <th>联系人姓名</th>
                                                <th>联系人号码</th>
                                                <th>邮箱</th>
                                                <th>备注</th>
                                                <th>操作</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <tr ms-repeat-item="grtxlData">
                                                <td>{{$index+1}}</td>
                                                <td><a ms-click="ViewForm(item.ID)"><i class="fa fa-pencil"></i> {{item.LXName}} </a></td>
                                                <td>{{item.LXHM}}</td>
                                                <td>{{item.LXMail}}</td>
                                                <td>{{item.LXRemark}}</td>
                                                <!--<td >{{item.CRDate|date("yyyy-MM-dd HH:mm")}}</td>-->
                                                <td style="width:150px">
                                                    <a class=" btn btn-primary btn-xs btntool" ms-click="ViewForm(item.ID)"><i class="fa fa-pencil"></i> 编辑 </a>
                                                    <a class="btn btn-danger btn-xs btntool" ms-click="DELForm(item)" style="margin-right:15px"><i class="fa fa-trash-o"></i> 删除 </a>
                                                </td>
                                            </tr>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
</html>
